package cn.iocoder.yudao.module.trade.order.vo;

import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.framework.validation.Discount;
import cn.iocoder.yudao.module.api.member.address.dto.MemberAddressRespDTO;
import cn.iocoder.yudao.module.api.promotion.groupon.dto.GrouponPackageRespDTO;
import cn.iocoder.yudao.module.api.shop.info.dto.ShopInfoDTO;
import cn.iocoder.yudao.module.api.trade.order.enums.TradeOrderTypeEnum;
import cn.iocoder.yudao.module.trade.order.bo.TradePriceCalculateRespBO;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Nonnull;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Schema(description = "用户 App - 交易订单结算信息 Response VO")
@Data
public class AppTradeOrderSettlementRespVO {

    @Schema(description = "店铺编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
    private Long shopId;

    @Schema(description = "店铺信息")
    private ShopInfoDTO shop;

    @Schema(description = "交易类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @InEnum(TradeOrderTypeEnum.class)
    private Integer type;

    @Schema(description = "支持的配送类型/服务方式数组：0-无、1-快递发货、2-到店自提、3-同城配送、4-现场核销、5-上门服务", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<Integer> supportDeliveryTypes;

    @Schema(description = "购物项", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<AppTradeOrderSettlementItemRespVO> items;

    @Schema(description = "团购套餐编号")
    @JsonInclude(value = JsonInclude.Include.NON_NULL)
    private Long grouponPackageId;

    @Schema(description = "团购套餐")
    @JsonInclude(value = JsonInclude.Include.NON_NULL)
    private GrouponPackageRespDTO grouponPackage;

    @SuppressWarnings("unused")
    @Nonnull
    public List<AppTradeOrderSettlementItemRespVO> getItems() {
        if (items == null) {
            items = new ArrayList<>();
        }
        return items;
    }

    @Schema(description = "优惠劵信息：可用 + 不可用", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<TradePriceCalculateRespBO.Coupon> coupons;

    @SuppressWarnings("unused")
    @Nonnull
    public List<TradePriceCalculateRespBO.Coupon> getCoupons() {
        if (coupons == null) {
            coupons = new ArrayList<>();
        }
        return coupons;
    }

    @Schema(description = "费用明细（总）", requiredMode = Schema.RequiredMode.REQUIRED)
    private AppTradeOrderSettlementPriceRespVO price;

    @Schema(description = "收货地址/服务地址，快递发货、骑手配送、上门服务时才会有")
    @JsonInclude(value = JsonInclude.Include.NON_NULL)
    private MemberAddressRespDTO address;

    @Schema(description = "已使用的积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
    private Integer deductPoint;

    @Schema(description = "用户总共的积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
    private Integer totalPoint;

    @Schema(description = "已使用的联盟豆", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
    private Integer deductCryptocurrency;

    @Schema(description = "用户总共的联盟豆", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
    private Integer totalCryptocurrency;

    @Schema(description = "首单优惠折扣，10 表示不打折", example = "10")
    @Discount
    private Double firstOrderDiscount;

    @Schema(description = "会员优惠折扣，10 表示不打折", example = "10")
    @Discount
    private Double vipDiscount;

    @Schema(description = "用餐人数", example = "0")
    private Integer dinePeoples;

    @Schema(description = "优惠明细")
    private List<TradePriceCalculateRespBO.Promotion> promotions;

}
